using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;


public class Props : MonoBehaviour
{

    public MeshRenderer text;

    public AlertBehaviour alert;

    public GameObject obj;

    public GameObject weapon;

    private void Start()
    {
        text.enabled = false;
    }
    private void Update()
    {
        if (alert.listTarget.Count > 0)
        {
            for (int i = 0; i < alert.listTarget.Count; i++)
            {
                PlayerCharacterController play = alert.listTarget[i].GetComponent<PlayerCharacterController>();
                if (play != null)
                {
                    text.enabled = true;
                    if (Input.GetKey(KeyCode.Q))
                    {
                        GameObject go = Instantiate(obj);
                        go.transform.position = transform.position;
                        play.AddWeapon(weapon);
                        play.ui.ChangebackSpace(play.weapons.Count);
                        Destroy(gameObject);
                        Destroy(go, 2f);
                    }
                }

            }
        }
        else
        {
            text.enabled = false;
        }
    }
}
